/*********************************This do file creates the spousal file from the 2000 Census*************************************/

/**********Remember: Change the directories before running the file********************************************************************/

/********merging spouses and cohabitors************/

/**creating a data set of women only**/

clear
set mem 8G
set matsize 1500
set more off

/***specify directory***/

use full2000.dta

drop if sex==1 /**dropping all men**/

gen spouseindi1=pernum

gen spouseindi2=sploc

save census00women.dta,replace


/**creating a data set of men only**/

clear
set mem 8G
set matsize 1500
set more off

use full2000.dta

drop if sex==2 /**dropping all women**/


foreach var of varlist * {
rename `var' `var'_m
}

gen spouseindi1=sploc

gen spouseindi2=pernum

rename  year_m year
rename serial_m serial

save census00men.dta,replace


/**merging spouses**/

clear
set mem 8G
set matsize 2000
set more off

use census00women.dta


merge 1:1 year serial spouseindi1 spouseindi2 using census00men.dta

drop if _merge==1
drop if _merge==2

/**dropping allocated age observations**/


keep if qage==0
keep if qage_m==0

/**dropping variables not used in the estimation**/

drop year serial pernum sploc relate related sex marrno qinctot cohab spouseindi1 spouseindi2 pernum_m sploc_m relate_m related_m sex_m marrno_m qinctot_m cohab_m _merge

save Couples2000.dta,replace


